package com.hcl.orm.sample.dao;

import com.hcl.orm.core.annotation.DBType;
import com.hcl.orm.core.annotation.SqlCommandType;
import com.hcl.orm.core.annotation.DataAccess;
import com.hcl.orm.core.annotation.Script;
import com.hcl.orm.sample.domain.Agency;

import java.util.List;

/**
 * @author hucl
 * @projectName jim-orm
 * @description: TODO
 * @date 2021/5/20 16:47
 */
@DataAccess
public interface CustomerAgencyDao extends AgencyDao {
    /**
     * 根据日期查询代理商
     *
     * @param updateDate
     * @param updateTime
     * @return
     */
    @Script(value = "SELECT company_name,update_date FROM prd_agency " +
            "WHERE 1=1 AND update_date < #{updateDate} [AND update_time=#{??updateTime}]")
    @Script(targetType = DBType.ORACLE,value = "SELECT company_name,update_date FROM prd_agency ")
    List<Agency> selectAgencyByDate(Integer updateDate, Integer updateTime);

    /**
     * 更新公司名称
     *
     * @param companyName
     * @param updateDate
     * @param newUpdateDate
     * @return
     */
    @Script(command = SqlCommandType.UPDATE, value = "UPDATE prd_agency SET company_name = #companyName,update_date = #newUpdateDate" +
            " WHERE update_date = #updateDate")
    Integer updateAgencyByDate(String companyName, Integer updateDate, Integer newUpdateDate);



}
